﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Public;
using System.Data;

namespace WebsiteAdmin.Password
{
    public partial class Password : System.Web.UI.Page
    {
        public string strUserName = Cookie.AdminLoginName;
        public string siteWeb = Global.SiteWeb;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Submit_ServerClick(object sender, EventArgs e)
        {
            string oldPwd = this.oldPwd.Value;
            DataTable dt = new Bll.Admin().Login(Global.ConSalomon, strUserName, oldPwd);
            if (dt.Rows.Count == 1)
            {
                try
                {
                    string newPwd = this.newPwd1.Value;
                    if (new Bll.Admin().UpdatePassword(Global.ConSalomon, strUserName, newPwd) == 1)                 //登录成功
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功！');document.location='" + siteWeb + "SkipPage.aspx'</script>");
                    }
                    else
                    {
                        this.ErrText.Text = "修改失败";
                    }
                }
                catch (Exception ex)
                {
                    this.ErrText.Text = ex.Message;
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('原密码错误');</script>");
            }
        }
    }
}
